-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0] stock_picking_batch_creation: Allows to split picking #932
base: 16.0
Are you sure you want to change the base?
Conversation
A new option 'Split picking exceeding the limits' on the wizard allow, when the system is not able to find a picking that fits the criteria to create the batch, to lower the criteria by removing those based on the volume, weight and number of lines. If a picking is found and you allow to split it, the system will try to split the picking so that the new picking fits the criteria and can be added to the batch.
31a03d0
to
785b794
Compare
785b794
to
c1d64ed
Compare
When we allow pickings to be split if one of the volume, weight or number of lines criteria exceeds the set limits, we take care to select the first picking to be processed in accordance with the processing order defined in the system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
The device can also define a limit of bins. I'll need this feature in v18.
As commented below, this needs to be split in multiple modules to not add new dependencies
nbr_lines, volume, weight = self._get_picking_max_dimensions() | ||
wizard = self.env["stock.split.picking"].with_context(active_ids=picking.ids) | ||
wizard.create( | ||
{ | ||
"mode": "dimensions", | ||
"max_nbr_lines": nbr_lines, | ||
"max_volume": volume, | ||
"max_weight": weight, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nbr_lines, volume, weight = self._get_picking_max_dimensions() | |
wizard = self.env["stock.split.picking"].with_context(active_ids=picking.ids) | |
wizard.create( | |
{ | |
"mode": "dimensions", | |
"max_nbr_lines": nbr_lines, | |
"max_volume": volume, | |
"max_weight": weight, | |
} | |
# In base split module | |
def _prepare_prepare_split_picking_wizard(self): | |
return { | |
"mode": self.split_picking_exceeding_limits_mode | |
} | |
# In split_dimension module | |
def _prepare_prepare_split_picking_wizard(self): | |
res = super()._prepare_prepare_split_picking_wizard() | |
if self.split_picking_exceeding_limits_mode == "dimensions": | |
nbr_lines, volume, weight = self._get_picking_max_dimensions() | |
res.update({ | |
"mode": "dimensions", | |
"max_nbr_lines": nbr_lines, | |
"max_volume": volume, | |
"max_weight": weight, | |
}) | |
return res | |
# In base split module | |
def _split_first_picking_for_limit(self, picking): | |
wizard = self.env["stock.split.picking"].with_context(active_ids=picking.ids) | |
wizard.create(self._prepare_split_picking_wizard()) |
nbr_lines, volume, weight = self._get_picking_max_dimensions() | ||
return ( | ||
picking.nbr_picking_lines > nbr_lines | ||
or picking.volume > volume | ||
or picking.weight > weight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nbr_lines, volume, weight = self._get_picking_max_dimensions() | |
return ( | |
picking.nbr_picking_lines > nbr_lines | |
or picking.volume > volume | |
or picking.weight > weight | |
# In base split module | |
def _is_picking_exceeding_limits(self, picking): | |
return False | |
# In split_dimension module | |
def _is_picking_exceeding_limits(self, picking): | |
if self.split_picking_exceeding_limits_mode == "dimensions": | |
nbr_lines, volume, weight = self._get_picking_max_dimensions() | |
return ( | |
picking.nbr_picking_lines > nbr_lines | |
or picking.volume > volume | |
or picking.weight > weight | |
) | |
return super()._is_picking_exceeding_limits(picking) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing this again, I think we should split this into multiple modules.
The existing module should not depend on new modules (there are quite some modules to split by dimension).
I would move the split to a new module stock_picking_batch_creation_split
defining split_picking_exceeding_limits
and the mode split_picking_exceeding_limits_mode
as a selection offering move
and depending on stock_split_picking
.
Edit: I think this move
mode is useless. Maybe split_picking_exceeding_limits
can be dropped and only the selection split_picking_exceeding_limits_mode
kept with a default behavior as no split
.
Then a module stock_picking_batch_creation_split_dimension
that declares the mode by dimension
and depends on stock_split_picking_dimension
.
Then I can add a module stock_picking_batch_creation_split_bins
that declares the mode by number of bins
and would depend on stock_split_picking_nbr_bins
.
# at this stage we have the first picking to add to the batch but it could | ||
# exceed the limits of the available devices. In this case we split the | ||
# picking and return the picking to add to the batch. The split is done only | ||
# if the split_picking_exceeding_limits is set to True. | ||
if ( | ||
picking | ||
and self.split_picking_exceeding_limits | ||
and self._is_picking_exceeding_limits(picking) | ||
): | ||
split_picking = self._split_first_picking_for_limit(picking) | ||
if not split_picking and raise_if_not_found: | ||
raise PickingSplitNotPossibleError(picking) | ||
picking = split_picking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to stock_picking_batch_creation_split
module
A new option 'Split picking exceeding the limits' on the wizard allow, when the system is not able to find a picking that fits the criteria to create the batch, to lower the criteria by removing those based on the volume, weight and number of lines. If a picking is found and you allow to split it, the system will try to split the picking so that the new picking fits the criteria and can be added to the batch.
Depends on: